<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>后台登陆系统NEW</title>
<%
	String path = (String) request.getContextPath();
%>
<script type="text/javascript" src="<%=path%>/js/plugins/jquery-1.7.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/plugins/easyUI/jquery.easyui.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/plugins/easyUI/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="<%=path%>/js/plugins/easyUI/plugins/jquery.dialog.js"></script>
<link rel="stylesheet" href="<%=path%>/js/plugins/easyUI/themes/bootstrap/easyui.css" type="text/css" />
<link rel="stylesheet" href="<%=path%>/js/plugins/easyUI/themes/icon.css" type="text/css" />
<link rel="stylesheet" href="<%=path%>/js/plugins/bootstrap-2.3.1/css/bootstrap.min.css" type="text/css" />
<script type="text/javascript">
	$(function(){
		$("#loginDialog").dialog({//初始化Dialog
			closable : false,
			title : "用户登录",
			width : 310,
			height : 200,
			buttons : [{
				text:'登录',
				handler:function(){
					loginFun();
				}
			},{
				text:'重置',
				handler:function(){
					$("#loginForm").form('clear');
				}
			}]

		});
		$('#loginForm input').bind('keyup', function(event) {/* 增加回车提交功能 */
			if (event.keyCode == '13') {
				loginFun();
			}
		});
	});
	
	function loginFun(){
		if($('#loginForm').form('validate')){
			$.messager.progress({
				title : '提示',
				text : '数据处理中，请稍后....'
			});
			$.ajax({
				type:'POST',
				url:'${pageContext.request.contextPath}/user/login',
				dataType:'json',
				data:$('#loginForm').serialize(),
				success:function(result){
					if(result.success == 'true'){
						$.messager.show('登录消息',result.msg,'slide');
						location.href = '${pageContext.request.contextPath}/user/main';  
					}else {
						$.messager.alert('错误',result.msg, 'error');
					}
					$.messager.progress('close');
				},
				error:function(XMLHttpRequest, textStatus, errorThrown){
					$.messager.alert("错误消息",'出现未知错误,请联系管理员','error');
					$.messager.progress('close');
				}
			});
		}
	}
</script>
</head>
<body>
	<div id="loginDialog">
		<form id="loginForm"  method="post">
			<table class="table table-hover table-condensed">
				<tr>
					<th>登录名</th>
					<td><input name="userName" type="text" placeholder="请输入登录名"
							class="easyui-validatebox" data-options="required:true"></td>
				</tr>
				<tr>
					<th>密码</th>
					<td><input name="passWord" type="password" placeholder="请输入密码"
							class="easyui-validatebox" data-options="required:true"></td>
				</tr>
			</table>
		</form>
	</div>
</body>
</html>